package com.xckj.teacher.ui.fragment

import androidx.fragment.app.activityViewModels
import com.blankj.utilcode.util.LogUtils
import com.xckj.teacher.ui.activity.CancelAccountActivity
import com.xckj.teacher.ui.activity.CancelExplainActivity
import com.xckj.teacher.R
import com.xckj.teacher.databinding.FragmentMyBinding
import com.xckj.teacher.framework.BaseFragment
import com.xckj.teacher.presenter.MainPresenter
import com.xckj.teacher.ui.App
import com.xckj.teacher.ui.activity.AboutAppActivity
import com.xckj.teacher.ui.activity.ContactServerActivity
import com.xckj.teacher.ui.activity.FeedBackActivity
import com.xckj.teacher.ui.activity.PersonDataActivity
import com.xckj.teacher.ui.appViewModel
import com.xckj.teacher.util.CustomBindAdapter
import com.xckj.teacher.util.startActivity

class MyFragment : BaseFragment<FragmentMyBinding?>() {

    override fun isStatusBarDarkFont(): Boolean {
        return false
    }


    override fun loadLayout(): Int {
        return R.layout.fragment_my
    }

    override fun setStatusBarColor(): Int {
        return R.color._4b90f6
    }

    override fun initData() {
        dataBinding?.click = ProxyClick()
        dataBinding?.userInfoData = appViewModel.userInfoData.value
        appViewModel.userInfoData.observe(this) {
            dataBinding?.userInfoData = it
        }
        appViewModel.lccal.observe(this) {
            LogUtils.e("wwwwwMy")
            CustomBindAdapter.circleImageUrl(dataBinding?.ivAvatar!!, it)
        }
    }

    inner class ProxyClick {


        fun userInfo() {
            startActivity(PersonDataActivity::class)
        }

        fun feed() {
            startActivity(FeedBackActivity::class)
        }

        fun contact() {
            startActivity(ContactServerActivity::class)

        }

        fun delete() {
            startActivity(CancelAccountActivity::class)

        }

        fun about() {
            startActivity(AboutAppActivity::class)

        }

        fun cancel() {
            startActivity(CancelExplainActivity::class)

        }

    }

    override fun onResume() {
        super.onResume()
//        if (appViewModel.lccal != "")
//            CustomBindAdapter.circleImageUrl(dataBinding?.ivAvatar!!, appViewModel.lccal)
    }
}
